<template>
    <div>
      <el-select v-model="category" placeholder="请选择分类" clearable>
        <el-option label="电子产品" value="电子产品"></el-option>
        <el-option label="服装" value="服装"></el-option>
        <el-option label="食品" value="食品"></el-option>
      </el-select>
      <el-input v-model="keyword" placeholder="请输入关键字" style="width: 200px; margin-left: 10px;"></el-input>
      <el-button type="primary" @click="search" style="margin-left: 10px;">搜索</el-button>
  
      <el-table :data="products" style="width: 100%; margin-top: 20px;">
        <el-table-column prop="name" label="产品名称"></el-table-column>
        <el-table-column prop="category" label="分类"></el-table-column>
        <el-table-column prop="description" label="描述"></el-table-column>
      </el-table>
    </div>
  </template>
  
  <script>
  import axios from 'axios';
  
  export default {
    data() {
      return {
        category: '',
        keyword: '',
        products: []
      };
    },
    methods: {
      search() {
        axios.get('http://localhost:8088/search', {
          params: {
            category: this.category,
            keyword: this.keyword
          }
        }).then(response => {
            console.log(response.data);
          this.products = response.data;
        });
      }
    }
  };
  </script>